package com.gof.example.command.macro;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Created by zhiyuan on 2018/5/10 10:47.
 * haiming.fei@tongdun.cn
 */
public class MicroCommand extends Command {

    private List<Command> commands = new ArrayList<>();

    public MicroCommand() {
    }

    public MicroCommand(Object object) {
        super(object);
    }

    @Override
    public void addCommand(Command c) {
        commands.add(c);
    }

    @Override
    public void removeCommand(Command c) {
        commands.remove(c);
    }

    @Override
    public Command getCommand(int i) {
        if (commands.size() > i) {
            return commands.get(i);
        }
        return null;
    }

    @Override
    void excute() {
        for (Command c : commands) {
            c.excute();
        }
    }
}
